//
//  UIView+Tool.h
//  BaseProject
//
//  Created by 小崔 on 2022/4/21.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSInteger,CRJShadowType) {
    CRJShadowTop    = 1,//上
    CRJShadowBottom = 2,//下
    CRJShadowLeft   = 3,//左
    CRJShadowRight  = 4,//右
    CRJShadowMiddle   = 0,//中间
    CRJShadowTopBottom  = 5,//上下
    CRJShadowLeftRight  = 6,//左右
    CRJShadowTopLeftRight  = 7,//上左右
    CRJShadowBottomLeftRight  = 8,//下左右
    CRJShadowAround = 9,//四周
};

@interface UIView (Tool)

#pragma mark --切圆角相关

/// 继承于UIView的视图切圆角
/// @param cornerType 圆角类型， 可看系统自带类型
/// @param radius 圆角角度
- (void)crj_setCornerType:(UIRectCorner)cornerType
             cornerRadius:(CGFloat)radius;

/// 继承于UIView的视图切圆角
/// @param rect 当前控件frame
/// @param cornerType 剪切类型
/// @param radius 圆角的角度
- (void)crj_setRoundedRect:(CGRect)rect
                cornerType:(UIRectCorner)cornerType
          cornerSizeRadius:(CGFloat)radius;

/// Layer
@property (nonatomic, strong) CAShapeLayer *crj_shapeLayer;

#pragma mark --添加阴影
/**
 给UIView添加阴影
 
 @param shadowColor 阴影颜色
 @param shadowOpacity 阴影透明度 默认0
 @param shadowRadius 阴影半径 也就是阴影放射程度 默认3
 @param shadowType 阴影方向
 @param shadowWidth 阴影放射宽度
 */
- (void)viewShadowWithColor:(UIColor *)shadowColor
              shadowOpacity:(CGFloat)shadowOpacity
               shadowRadius:(CGFloat)shadowRadius
             shadowPathType:(CRJShadowType)shadowType
                shadowWidth:(CGFloat)shadowWidth;
/**
 给不规则UIView添加阴影
 
 @param shadowColor 阴影颜色
 @param shadowOpacity 阴影透明度 默认0
 @param shadowRadius 阴影半径 也就是阴影放射程度 默认3
 @param shadowType 阴影方向
 @param shadowWidth 阴影放射宽度
 */
- (void)viewShadowWithBackgroundViewColor:(UIColor *)shadowColor
                            shadowOpacity:(CGFloat)shadowOpacity
                             shadowRadius:(CGFloat)shadowRadius
                           shadowPathType:(CRJShadowType)shadowType
                              shadowWidth:(CGFloat)shadowWidth;
// 添加四边阴影效果
- (void)addShadowToViewColor:(UIColor *)theColor
               shadowOpacity:(CGFloat)shadowOpacity
                shadowRadius:(CGFloat)shadowRadius;
/// 将View生成一个UIImage图片
- (UIImage *)generateImage;

@end

NS_ASSUME_NONNULL_END
